// pages/home/index.js
import * as request from "../../utils/request/folder/index"

Page({
  data: {
    folderList: [],
    fatherTypeArr: [],
    
  },
  /**
   * 生命周期函数--监听页面加载
   */
  async onLoad(options) {
    console.log(options)
    let session = wx.getStorageSync('session')
    let id = options.id
    let arr = []
    arr = this.data.fatherTypeArr
   
    let typeName = options.typeName
    arr.push(typeName)
    this.setData({
      fatherTypeArr:arr
    })
    console.log(id,typeName)
    try {
      let res = await request.getSecondFolder({
        PType:id
      }, session)
      
      console.log(res)
      if (res.code === 0) {
        this.setData({
          folderList: res.data
        })
      }
    } catch (err) {
      console.log(err)
      wx.showToast({
        title: '获取失败',
        icon: "none"
      })
    }
  },
  /**
   * 仅负责跳转页面
   */
  handleClick(e) {
    let index = e.currentTarget.dataset.id
    let {id ,typeName} = this.data.folderList[index]  
    let arr  = []
    arr = this.data.fatherTypeArr
    arr.push(typeName)
    console.log(id,arr)
    wx.navigateTo({
      url: `../region/index?id=${id}&typeName=${typeName}&typeArr=${arr}`,
    })
  }

})